<?php

class User extends connection {
    
    public $stud_id;
    public $stud_lname;
    public $stud_fname;
    public $stud_mname;
    public $stud_bday;
    public $stud_gender;
    public $stud_age;
    public $stud_pbirth;
    public $stud_religion;
    public $stud_address;
    public $stud_nation;
    public $stud_contact;
    public $stud_guardian;
    public $stud_sy;
    public $stud_yearlevel;
    
    public function save_user()
    {
        $sql = "INSERT INTO `tbl_student`(`stud_id`,`stud_lname`,`stud_fname`,`stud_mname`,
        `stud_bday`,`stud_gender`,`stud_age`,`stud_pbirth`,`stud_religion`,`stud_address`,`stud_nation`,
        `stud_contact`,`stud_guardian`,`stud_sy`,`stud_yearlevel`)
        
        VALUES (
            '".$this->stud_id."',
            '".$this->stud_lname."',
            '".$this->stud_fname."',
            '".$this->stud_mname."',
            '".$this->stud_bday."',
            '".$this->stud_gender."',
            '".$this->stud_age."',
            '".$this->stud_pbirth."',
            '".$this->stud_religion."',
            '".$this->stud_address."',
            '".$this->stud_nation."',
            '".$this->stud_contact."',
            '".$this->stud_guardian."',
            '".$this->stud_sy."',
            '".$this->stud_yearlevel."'


        )
        ";
        
        try
        {
            return $this->query($sql);
        }
        catch(Exception $e)
        {
            throw $e;
        }
        
    }
    
    
      public function login()
    {
            $sql = "SELECT * FROM `tbl_log_admin` WHERE `username`='".$this->username."' AND `password`='".$this->password."'";
            
            try
            {
                $result = $this->query($sql);
                if(mysql_num_rows( $result)>0)
                {
                    return true;
                }
                 else   
                {
                    return false;
                }
                
            }
            catch(Exception $e)
            {
                throw $e;
            }
    }
    
     public function Slogin()
    {
            $sql = "SELECT * FROM `tbl_student` WHERE `stud_id`='".$this->stud_id."' AND `stud_lname`='".$this->stud_lname."'";
            
            try
            {
                $result = $this->query($sql);
                if(mysql_num_rows( $result)>0)
                {
                    return true;
                }
                 else   
                {
                    return false;
                }
                
            }
            catch(Exception $e)
            {
                throw $e;
            }
    }
    
    
}
?>